﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

public partial class Admin_viewreport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        drop.SelectedIndexChanged += new EventHandler(drop_SelectedIndexChanged);
        if (!IsPostBack)
        {

            busSinhVien busD = new busSinhVien();

            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/admin/report/sinhvien.rdlc");
            List<entSinhVien> lst = new List<entSinhVien>();
            lst = busD.getSinhVienAll();

            ReportDataSource report = new ReportDataSource();
            report.Name = "DataSet1";
            report.Value = lst;
            ReportViewer1.LocalReport.DataSources.Add(report);
        }
    }

    void drop_SelectedIndexChanged(object sender, EventArgs e)
    {
        ReportViewer1.Reset();
        if (drop.SelectedValue == "2")
        {
            busDiem busD = new busDiem();

            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/admin/report/diem.rdlc");
            List<entDiem> lst = new List<entDiem>();
            lst = busD.getDiemChuongTrinhDT("511411001");

            ReportDataSource report = new ReportDataSource();
            report.Name = "DataSet1";
            report.Value = lst;
            ReportViewer1.LocalReport.DataSources.Add(report);
        }
        else
        {
            busSinhVien busD = new busSinhVien();

            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/admin/report/sinhvien.rdlc");
            List<entSinhVien> lst = new List<entSinhVien>();
            lst = busD.getSinhVienAll();

            ReportDataSource report = new ReportDataSource();
            report.Name = "DataSet1";
            report.Value = lst;
            ReportViewer1.LocalReport.DataSources.Add(report);
        }
    }
}